"use strict";

/**
 * @param {Egg.Application} app - egg application
 */
module.exports = (app) => {
  const { router, controller } = app;
  // user controller
  router.post("/user/createUser", controller.user.createUser);
  router.post("/user/login", controller.user.login);
  // project controller
  router.get("/project/template", controller.project.getTemplate);
  router.post("/project/add", controller.project.addTemplate);
  router.get("/project/oss", controller.project.getOSSProject);
  router.get("/oss/get", controller.project.getOSSFile);
  router.get("/redis/test", controller.project.getRedis);
  // page controller
  router.get("/page/template", controller.page.getTemplate);
  router.post("/page/add", controller.page.addTemplate);
  // section controller
  router.get("/section/template", controller.section.getTemplate);
  router.post("/section/add", controller.section.addTemplate);
  // monitor controller
  router.get("/monitor/upload", controller.monitor.upload);
  router.post("/monitor/upload", controller.monitor.upload);
  router.get("/monitor/feature", controller.monitor.getFeature);
  // RESUL API
  router.resources(
    "components",
    "/api/v1/components",
    controller.v1.components
  );
  router.resources(
    "componentSite",
    "/api/v1/componentSite",
    controller.v1.componentSite
  );
  // socket.emit('build')
  app.io.route("build", app.io.controller.build.index);
};
